package com.starview.star.operators.string.runtime;

import com.starview.platform.data.EvaluationException;
import com.starview.platform.data.IFunction;
import com.starview.platform.data.IValue;
import com.starview.platform.data.type.IType;
import com.starview.platform.data.type.Refresher;
import com.starview.platform.data.type.StandardTypes;
import com.starview.platform.data.type.TypeUtils;
import com.starview.platform.data.type.TypeVar;
import com.starview.platform.data.value.Factory;
import com.starview.platform.data.value.StringWrap;
import com.starview.star.operators.CafeEnter;

/**
 * Implement display of stuff
 * 
 * @author fgm
 * 
 */
public class DisplayTerm implements IFunction
{
  public static final String name = "__display";

  @CafeEnter
  public static StringWrap enter(IValue value) throws EvaluationException
  {
    return Factory.newString(ValueDisplay.display(value));
  }

  @Override
  public IValue enter(IValue... args) throws EvaluationException
  {
    return enter(args[0]);
  }

  @Override
  public IType getType()
  {
    return funType();
  }

  public static IType funType()
  {
    return Refresher.generalize(TypeUtils.functionType(new TypeVar(), StandardTypes.stringType));
  }
}
